package duoqiao;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Try1 {
    public static void main(String[] args) {
        try {
            readText("D:\\a.txt.txt");
        }catch (FileNotFoundException e){
            e.printStackTrace();
        }catch (FileTypeException e){
            e.printStackTrace();
        }
    }


    public static String readText(String path) throws FileNotFoundException,FileTypeException {
        if (!new File(path).exists())
            throw new FileNotFoundException("文件路径找不到！！");

        if (!path.endsWith(".md"))
            throw new FileTypeException("文件类型不对!!");
        return null;
    }
}
//自定义异常
class FileTypeException extends IOException {
    public FileTypeException(){
    }

    public FileTypeException(String message){
        super(message);
    }
}
